<?php

Raise::load('core.datetime.RaiseTimer');

/**
 * TestCoreRaiseTimer class
 * Testing unit of 'phpraise/core/RaiseTimer.php'
 *
 * @author Sam-Mauris Yong / hellclanner at live dot com
 * @license http://www.opensource.org/licenses/bsd-license New BSD License
 * @package Raise.UnitTest.Test
 */
class TestCoreRaiseTimer extends RaiseTest {

    public static function testClass(){
        self::assertClassExists('RaiseTimer');
        self::assertClassExtends('RaiseTimer', 'RaiseObject');
        self::assertClassImplements('Raisetimer', 'IRaiseComparable');
    }

    public static function testTimer(){
        $timer = new RaiseTimer(false);
        self::assertObjectClass($timer, 'RaiseTimer');
        self::assertFalse($timer->isRunning());
        $timer->start();
        self::assertTrue($timer->isRunning());
        $timer->reset();
        self::assertFalse($timer->isRunning());

        $timer->start();
        self::assertTrue($timer->isRunning());
        $i = 0;
        while($i++ < 100){}
        self::assertType($timer->stop(), 'double');
        self::assertFalse($timer->isRunning());
        self::assertType($timer->result(), 'double');
        self::assertTrue($timer->result() > 0);
    }
    
}